package com.kelvem.saas.workbanch.ontology.carrier.feiyang.controller;

import com.alibaba.fastjson.JSONObject;
import com.kelvem.saas.workbanch.core.base.BaseController;
import com.kelvem.saas.workbanch.ontology.carrier.feiyang.dao.FeiyangReturnDao;
import com.kelvem.saas.workbanch.ontology.carrier.feiyang.dao.FeiyangTrackDao;
import com.kelvem.saas.workbanch.ontology.carrier.feiyang.request.FeiyangReturnReq;
import com.kelvem.saas.workbanch.ontology.carrier.feiyang.request.FeiyangTrackReq;
import com.kelvem.saas.workbanch.ontology.carrier.feiyang.response.FeiyangNotifyResp;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/carrier/feiyang")
public class FeiyangCarrierController extends BaseController {

    @Resource
    private FeiyangReturnDao feiyangReturnDao;
    
    @Resource
    private FeiyangTrackDao feiyangTrackDao;
    
    @RequestMapping("/notifyTrack")
    public FeiyangNotifyResp notifyTrack(@RequestParam String param) {
        // {param={"GoodsSelfNumber":"7914-1","InHouseIdentifier":"2017","OriginalDocumentNumber":"1605687914","TransportStatusCode":"5","PlaceOrLocationIdentification":"哈尔滨","NameOfPerson":"hrbb","MessageFunctionCode":"02","ShippingNoteNumber":"2011181698","StatusChangeDateTime":"20201118163258","Remark":"哈尔滨已揽件，发往张国的1件ZP:一口膏*1准备发往下一站。网点电话:045187523123"}}
        System.out.println(param);
        FeiyangTrackReq req = JSONObject.parseObject(param, FeiyangTrackReq.class);
        feiyangTrackDao.insert(req);
    
        return new FeiyangNotifyResp(req);
    }
    
    @RequestMapping("/notifyReturn")
    public FeiyangNotifyResp notifyReturn(@RequestParam String param) {
        // {param={"code":"001","orderNo":"2011191701","success":true,"OriginalDocumentNumber":"1605766331","documentQueueNo":"1605766331","message":"成功","messageGuid":"1605766331"}
        System.out.println(param);
        FeiyangReturnReq req = JSONObject.parseObject(param, FeiyangReturnReq.class);
        feiyangReturnDao.insert(req);
        
        return new FeiyangNotifyResp(req);
    }
}
